package cn.iocoder.yudao.module.nmkj.controller.app.newscontent;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.nmkj.controller.admin.newscontent.vo.NewsContentPageReqVO;
import cn.iocoder.yudao.module.nmkj.controller.admin.newscontent.vo.NewsContentRespVO;
import cn.iocoder.yudao.module.nmkj.dal.dataobject.newscontent.NewsContentDO;
import cn.iocoder.yudao.module.nmkj.service.newscontent.NewsContentService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "用户APP - 新闻内容")
@RestController
@RequestMapping("/nmkj/news-content")
@Validated
public class AppNewsContentController {

    @Resource
    private NewsContentService newsContentService;

    @GetMapping("/get")
    @Operation(summary = "获得新闻内容")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    public CommonResult<NewsContentRespVO> getNewsContent(@RequestParam("id") Long id) {
        NewsContentDO newsContent = newsContentService.getNewsContentApp(id);
        //用户端请求的数据必须为启用状态
        return success(BeanUtils.toBean(newsContent, NewsContentRespVO.class));
    }

}
